Add session management migration chapter
authorMatthias Clasen <mclasen@redhat.com>
Sun, 8 Jan 2012 02:44:52 +0000 (21:44 -0500)
committerMatthias Clasen <mclasen@redhat.com>
Sun, 8 Jan 2012 02:44:52 +0000 (21:44 -0500)
Add some preliminary information about migration from EggSMClient
to GtkApplication.

docs/reference/gtk/Makefile.am
docs/reference/gtk/gtk-docs.sgml
docs/reference/gtk/migrating-GtkApplication.xml [deleted file]
docs/reference/gtk/migrating-smclient-GtkApplication.xml [new file with mode: 0644]
docs/reference/gtk/migrating-unique-GtkApplication.xml [new file with mode: 0644]

index d0d19e6c4c6909dd2cf32548ba1932c638d17cd0..54f3c7a33d52904c638a684bce8a5d1cc9ffa3a0 100644 (file)
@@ -123,7 +123,8 @@ content_files =                                     \
        glossary.xml                            \
        migrating-2to3.xml                      \
        migrating-checklist.sgml                \
-       migrating-GtkApplication.xml            \
+       migrating-unique-GtkApplication.xml     \
+       migrating-smclient-GtkApplication.xml   \
        migrating-GtkGrid.xml                   \
        migrating-GtkStyleContext.xml           \
        objects_grouped.sgml                    \
@@ -146,7 +147,8 @@ expand_content_files =                              \
        glossary.xml                            \
        migrating-2to3.xml                      \
        migrating-checklist.sgml                \
-       migrating-GtkApplication.xml            \
+       migrating-unique-GtkApplication.xml     \
+       migrating-smclient-GtkApplication.xml   \
        migrating-GtkGrid.xml                   \
        migrating-GtkStyleContext.xml           \
        question_index.sgml                     \
index baf190578ba3d3bc8b80c641af53ddd8aafa8623..9be29d7de0fef1ca4175ecf35038783c9d37171a 100644 (file)
 
     <xi:include href="xml/migrating-2to3.xml" />
     <xi:include href="xml/migrating-GtkStyleContext.xml" />
-    <xi:include href="xml/migrating-GtkApplication.xml" />
+    <xi:include href="xml/migrating-unique-GtkApplication.xml" />
+    <xi:include href="xml/migrating-smclient-GtkApplication.xml" />
     <xi:include href="xml/migrating-GtkGrid.xml" />
     <xi:include href="xml/migrating-checklist.sgml" />
   </part>
diff --git a/docs/reference/gtk/migrating-GtkApplication.xml b/docs/reference/gtk/migrating-GtkApplication.xml
deleted file mode 100644 (file)
index a53f165..0000000
+++ /dev/null
@@ -1,143 +0,0 @@
-<?xml version="1.0"?>
-<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN"
-               "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd" [
-]>
-<chapter id="gtk-migrating-GtkApplication">
-
-  <title>Migrating from libunique to GApplication or GtkApplication</title>
-
-  <para>
-    libunique offers 'unique application' support as well as ways to
-    communicate with a running application instance. This is implemented
-    in various ways, either using D-Bus, or socket-based communication.
-  </para>
-
-  <para>
-    Starting with GLib 2.26, D-Bus support has been integrated into GIO
-    in the form of GDBus, and #GApplication has been added to provide
-    the same level of application support as libunique.
-  </para>
-
-  <example><title>A unique application</title>
-  <para>Here is a simple application using libunique:
-  <programlisting>
-int
-main (int argc, char *argv[])
-{
-  UniqueApp *app;
-  GtkWidget *window;
-
-  gtk_init (&amp;argc, &amp;argv);
-
-  app = unique_app_new ("org.gtk.TestApplication", NULL);
-
-  if (unique_app_is_running (app))
-    {
-      UniqueResponse response;
-
-      response = unique_app_send_message (app, UNIQUE_ACTIVATE, NULL);
-      g_object_unref (app);
-
-      return response == UNIQUE_RESPONSE_OK ? 0 : 1;
-    }
-
-  window = create_my_window ();
-
-  unique_app_watch_window (app, GTK_WINDOW (window));
-
-  gtk_widget_show (window);
-
-  gtk_main ();
-
-  g_object_unref (app);
-
-  return 0;
-}
-</programlisting>
-The same application using GtkApplication:
-<programlisting>
-static void
-activate (GtkApplication *app)
-{
-  GList *list;
-  GtkWidget *window;
-
-  list = gtk_application_get_windows (app);
-
-  if (list)
-    {
-      gtk_window_present (GTK_WINDOW (list->data));
-    }
-  else
-    {
-      window = create_my_window ();
-      gtk_window_set_application (GTK_WINDOW (window), app);
-      gtk_widget_show (window);
-    }
-}
-
-int
-main (int argc, char *argv[])
-{
-  GtkApplication *app;
-  gint status;
-
-  app = gtk_application_new ("org.gtk.TestApplication", 0);
-  g_signal_connect (app, "activate", G_CALLBACK (activate), NULL);
-
-  status = g_application_run (app);
-
-  g_object_unref (app);
-
-  return status;
-}
-</programlisting>
-</para>
-</example>
-  <section><title>Uniqueness</title>
-    <para>
-      Instead of creating a #UniqueApp with unique_app_new(), create
-      a #GApplication with g_application_new() or a #GtkApplication
-      with gtk_application_new(). The @name that was used with
-      unique_app_new() is very likely usable as the @application_id for
-      g_application_new() without any changes, and GtkApplication passes
-      the <envar>DESKTOP_STARTUP_ID</envar> environment variable
-      automatically.
-    </para>
-    <para>
-      While libunique expects you to check for an already running instance
-      yourself and activate it manually, GApplication handles all this on
-      its own in g_application_run(). If you still need to find out if there
-      is a running instance of your application, use
-      g_application_get_is_remote() instead of unique_app_is_running().
-    </para>
-  </section>
-
-  <section><title>Commands and Messages</title>
-    <para>
-      libunique lets you send messages with commands to a running
-      instance using unique_app_send_message(). The commands can be either
-      predefined or custom. Some of the predefined libunique commands have
-      equivalents in GApplication. Instead of sending the %UNIQUE_ACTIVATE
-      command, call g_application_activate(), instead of sending the
-      %UNIQUE_OPEN command, call g_application_open(). The
-      %UNIQUE_NEW and %UNIQUE_CLOSE and user-defined commands don't
-      have direct replacement at this time.
-    </para>
-
-    <para>
-      As a replacement for custom commands, GApplication implements the
-      #GActionGroup interface and lets you add a group of actions with
-      g_application_set_action_group(). The actions can then be invoked,
-      either by using the D-Bus interface for #GAction directly, or by
-      calling g_action_group_activate_action() from another instance of
-      the GApplication. The #GApplication documentation contains an
-      example for using GApplication with actions.
-    </para>
-
-    <para>
-      For more complex needs, GApplication supports passing entire
-      commandlines to the running instance.
-    </para>
-  </section>
-</chapter>
diff --git a/docs/reference/gtk/migrating-smclient-GtkApplication.xml b/docs/reference/gtk/migrating-smclient-GtkApplication.xml
new file mode 100644 (file)
index 0000000..58cae9a
--- /dev/null
@@ -0,0 +1,49 @@
+<?xml version="1.0"?>
+<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN"
+               "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd" [
+]>
+<chapter id="gtk-migrating-smclient-GtkApplication">
+
+  <title>Migrating from EggSMClient to GtkApplication</title>
+
+  <para>
+    EggSMClient provides 'session management' support for applications.
+    This means a number of things:
+    <itemizedlist>
+      <listitem>logout notification and negotiation</listitem>
+      <listitem>application state saving</listitem>
+      <listitem>restarting of applications with saved state</listitem>
+    </itemizedlist>
+    EggSMClient supports this functionality to varying degrees on
+    Windows and OS X, as well as with XSMP and D-Bus based session
+    managers in X11.
+  </para>
+
+  <para>
+    Starting with GTK+ 3.4, #GtkApplication supports logout notification
+    and negotiation in the same way as EggSMClient, using the same
+    basic API:
+  </para>
+  <table>
+    <tgroup cols="2">
+      <title>EggSMClient to GtkApplication</title>
+      <thead>
+        <row><entry>EggSMClient</entry><entry>GtkApplication</entry></row>
+      </thead>
+      <tbody>
+        <row><entry>EggSMClient::quit-requested</entry><entry>#GtkApplication::quit-requested</entry></row>
+        <row><entry>EggSMClient::quit</entry><entry>#GtkApplication::quit</entry></row>
+        <row><entry>EggSMClient::quit-cancelled</entry><entry>#GtkApplication::quit-cancelled</entry></row>
+        <row><entry>egg_sm_client_will_quit</entry><entry>gtk_application_quit_response()</entry></row>
+        <row><entry>egg_sm_client_end_session</entry><entry>gtk_application_end_session()</entry></row>
+      </tbody>
+    </tgroup>
+  </table>
+
+  <para>
+    At this point, GtkApplication has no special support for state saving.
+    Applications can use GSettings or GKeyFile and save as much state as
+    they see fit in response to #GtkApplication::quit or whenever they
+    consider appropriate.
+  </para>
+</chapter>
diff --git a/docs/reference/gtk/migrating-unique-GtkApplication.xml b/docs/reference/gtk/migrating-unique-GtkApplication.xml
new file mode 100644 (file)
index 0000000..aaa6645
--- /dev/null
@@ -0,0 +1,143 @@
+<?xml version="1.0"?>
+<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN"
+               "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd" [
+]>
+<chapter id="gtk-migrating-unique-GtkApplication">
+
+  <title>Migrating from libunique to GApplication or GtkApplication</title>
+
+  <para>
+    libunique offers 'unique application' support as well as ways to
+    communicate with a running application instance. This is implemented
+    in various ways, either using D-Bus, or socket-based communication.
+  </para>
+
+  <para>
+    Starting with GLib 2.26, D-Bus support has been integrated into GIO
+    in the form of GDBus, and #GApplication has been added to provide
+    the same level of application support as libunique.
+  </para>
+
+  <example><title>A unique application</title>
+  <para>Here is a simple application using libunique:
+  <programlisting>
+int
+main (int argc, char *argv[])
+{
+  UniqueApp *app;
+  GtkWidget *window;
+
+  gtk_init (&amp;argc, &amp;argv);
+
+  app = unique_app_new ("org.gtk.TestApplication", NULL);
+
+  if (unique_app_is_running (app))
+    {
+      UniqueResponse response;
+
+      response = unique_app_send_message (app, UNIQUE_ACTIVATE, NULL);
+      g_object_unref (app);
+
+      return response == UNIQUE_RESPONSE_OK ? 0 : 1;
+    }
+
+  window = create_my_window ();
+
+  unique_app_watch_window (app, GTK_WINDOW (window));
+
+  gtk_widget_show (window);
+
+  gtk_main ();
+
+  g_object_unref (app);
+
+  return 0;
+}
+</programlisting>
+The same application using GtkApplication:
+<programlisting>
+static void
+activate (GtkApplication *app)
+{
+  GList *list;
+  GtkWidget *window;
+
+  list = gtk_application_get_windows (app);
+
+  if (list)
+    {
+      gtk_window_present (GTK_WINDOW (list->data));
+    }
+  else
+    {
+      window = create_my_window ();
+      gtk_window_set_application (GTK_WINDOW (window), app);
+      gtk_widget_show (window);
+    }
+}
+
+int
+main (int argc, char *argv[])
+{
+  GtkApplication *app;
+  gint status;
+
+  app = gtk_application_new ("org.gtk.TestApplication", 0);
+  g_signal_connect (app, "activate", G_CALLBACK (activate), NULL);
+
+  status = g_application_run (app);
+
+  g_object_unref (app);
+
+  return status;
+}
+</programlisting>
+</para>
+</example>
+  <section><title>Uniqueness</title>
+    <para>
+      Instead of creating a #UniqueApp with unique_app_new(), create
+      a #GApplication with g_application_new() or a #GtkApplication
+      with gtk_application_new(). The @name that was used with
+      unique_app_new() is very likely usable as the @application_id for
+      g_application_new() without any changes, and GtkApplication passes
+      the <envar>DESKTOP_STARTUP_ID</envar> environment variable
+      automatically.
+    </para>
+    <para>
+      While libunique expects you to check for an already running instance
+      yourself and activate it manually, GApplication handles all this on
+      its own in g_application_run(). If you still need to find out if there
+      is a running instance of your application, use
+      g_application_get_is_remote() instead of unique_app_is_running().
+    </para>
+  </section>
+
+  <section><title>Commands and Messages</title>
+    <para>
+      libunique lets you send messages with commands to a running
+      instance using unique_app_send_message(). The commands can be either
+      predefined or custom. Some of the predefined libunique commands have
+      equivalents in GApplication. Instead of sending the %UNIQUE_ACTIVATE
+      command, call g_application_activate(), instead of sending the
+      %UNIQUE_OPEN command, call g_application_open(). The
+      %UNIQUE_NEW and %UNIQUE_CLOSE and user-defined commands don't
+      have direct replacement at this time.
+    </para>
+
+    <para>
+      As a replacement for custom commands, GApplication implements the
+      #GActionGroup interface and lets you add a group of actions with
+      g_application_set_action_group(). The actions can then be invoked,
+      either by using the D-Bus interface for #GAction directly, or by
+      calling g_action_group_activate_action() from another instance of
+      the GApplication. The #GApplication documentation contains an
+      example for using GApplication with actions.
+    </para>
+
+    <para>
+      For more complex needs, GApplication supports passing entire
+      commandlines to the running instance.
+    </para>
+  </section>
+</chapter>